package com.offcn.search.controller;

import com.offcn.entity.Result;
import com.offcn.entity.StatusCode;
import com.offcn.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/search")
@CrossOrigin
public class SearchController {

    @Autowired
    private SearchService searchService;

    @GetMapping("/import")
    public Result importEs(){
        searchService.importEs();
        return new Result(true, StatusCode.OK,"导入成功！");
    }

    @GetMapping
    public Map search(@RequestParam(required = false) Map searchMap){
        return searchService.search(searchMap);
    }
}
